import API from "@common/api.js"
import userStore from "../../common/userStore";
function updateUserInfo() {
    API.getUserInfo().then(
        (res) => {
            console.log("用户登录成功！！");
            console.log(res);
            let ret ={type: "user", isLogin: true};
            let data = res['data'];
            console.log("data is");
            console.log(data);
            for(let k in data) {
                ret[k] = data[k];
            }
            userStore.dispatch(ret);
            let state = userStore.getState();
            console.log("The result state is:");
            console.log(state);
        },
        (res) => {
            console.log("用户未登录！！");
            // console.log(tmpPromise);
            userStore.dispatch({type: "user", isLogin: false});
        }
    );
}
export default updateUserInfo;